using System;

namespace Sedna.Core.Messaging
{
	public class NamedEndPoint : IEndPoint
	{
		private string name;

		public NamedEndPoint()
		{
		}

		public NamedEndPoint(string name)
		{
			this.name = name;
		}

		public virtual string Name
		{
			get { return name; }
			set { name = value; }
		}

		public override string ToString()
		{
			return Name;
		}

		public override bool Equals(object obj)
		{
			IEndPoint that = obj as IEndPoint;
			return that!=null && this.Name==that.Name;
		}

		public override int GetHashCode()
		{
			return this.Name.GetHashCode();
		}

		public static bool operator == (NamedEndPoint a, IEndPoint b)
		{
			return a.Equals(b);
		}

		public static bool operator != (NamedEndPoint a, IEndPoint b)
		{
			return !a.Equals(b);
		}
	}
}
